//load weixin js sdk
var ua_explorer = window.navigator.userAgent.toLowerCase();
if (ua_explorer.match(/MicroMessenger/i) == "micromessenger") {
    getScriptX("//res.wx.qq.com/open/js/jweixin-1.0.0.js");
}

function getScriptX(script) {
    $.ajax({
        url: script,
        dataType: "script",
        async: true, // <-- This is the key
        success: function () {
            $.getScript("/program/linkage_page/mgm2016_event07/js/wx_config.js");
        },
        error: function () {
            throw new Error("Could not load script " + script);
        }
    });
}

var shareTitle = "XXX与外教练习口语已经XXX天，坚持的秘密就在这里！";
var shareDesc = "你的朋友有一节1对1外教英语体验课免费送给你，点击领取";
var shareLink = '';
var shareImgUrl = "http://source.vipabc.com/ext/images/website/abc/linkage_page/mgm2016_event07/weChat.jpg";

function wxAPIConfig() {
    wxShareConfig(shareTitle, shareDesc, shareLink, shareImgUrl);
}

function wxShareConfig(shareTitle, shareDesc, shareLink, shareImgUrl) {

    // 2.1 监听“分享给朋友”，按钮点击、自定义分享内容及分享结果接口
    //document.querySelector('#onMenuShareAppMessage').onclick = function () {
    wx.onMenuShareAppMessage({
        title: shareTitle,
        desc: shareDesc,
        link: shareLink,
        imgUrl: shareImgUrl,
        success: function () {
            $('.mask2').hide();
        },
        cancel: function () {}
    });

    // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
    //document.querySelector('#onMenuShareTimeline').onclick = function () {
    wx.onMenuShareTimeline({
        title: shareTitle,
        link: shareLink,
        imgUrl: shareImgUrl,
        success: function () {
            $('.mask2').hide();
        },
        cancel: function () {}
    });


    // 2.3 监听“分享到QQ”按钮点击、自定义分享内容及分享结果接口
    //document.querySelector('#onMenuShareQQ').onclick = function () {
    wx.onMenuShareQQ({
        title: shareTitle,
        desc: shareDesc,
        link: shareLink,
        imgUrl: shareImgUrl,
        success: function () {
            $('.mask2').hide();
        },
        cancel: function () {}
    });


    // 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口
    //document.querySelector('#onMenuShareWeibo').onclick = function () {
    wx.onMenuShareWeibo({
        title: shareTitle,
        desc: shareDesc,
        link: shareLink,
        imgUrl: shareImgUrl,
        success: function () {
            $('.mask2').hide();
        },
        cancel: function () {}
    });

}
